<script>
import { useLoginStore } from '@/stores/login';
import { mapState } from 'pinia';

export default {
    name: 'Mine',
    computed: {
        ...mapState(useLoginStore, { username: 'loginName', logined: 'logined'})
    },
    // 组件生命周期钩子
    beforeMount() {
        //若用户尚未登录
        if( !this.logined ){
            //则导航到登录界面
            this.$router.push( {name: 'pcLogin' } );
        }
    }
}

</script>

<template>
    <h1>Mine</h1>
    <p>welcome{{ username }}.</p>
</template>